package com.yimixian.app.model;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.util.Log;

import com.squareup.picasso.Transformation;
import com.yimixian.app.ui.PlusMinusIcon;

/**
 * Created by Administrator on 2016/5/10 0010.
 */
public class PicassoTransformation implements Transformation {

    private Context mContext;
    private String key;
    private PlusMinusIcon mPlusMinusIcon;
    private OnBitmapFinishLoadedListener bitmapFinishLoadedListener;

    public PicassoTransformation(Context mContext, String key, PlusMinusIcon mPlusMinusIcon, OnBitmapFinishLoadedListener bitmapFinishLoadedListener) {
        this.mContext = mContext;
        this.key = key;
        this.mPlusMinusIcon = mPlusMinusIcon;
        this.bitmapFinishLoadedListener = bitmapFinishLoadedListener;
    }

    @Override
    public Bitmap transform(Bitmap source) {
        if(bitmapFinishLoadedListener != null){
            bitmapFinishLoadedListener.onFinish(source, mPlusMinusIcon);
        }
        return source;
    }

    @Override
    public String key() {
        return key;
    }

    public interface OnBitmapFinishLoadedListener{
        public void onFinish(Bitmap bitmap, PlusMinusIcon mPlusMinusIcon);
    }
}
